import request from '@/config/axios'
import type {AuthorityModifiedResponse} from '@/model/authority-import'

export const getAuthorityInfoApi = () => {
	return request.post<AuthorityInfo>({
		url: '/system/sys-authority/readOnly/getAuthorityInfo',
	})
}

export const saveAuthorityApi = (data: SysAuthority) => {
	return request.post<AuthorityModifiedResponse | undefined>({
		url: '/system/sys-authority/saveAuthority',
		data
	})
}

export const saveRoleAuthorityApi = (data: SaveRoleAuthorityRequest) => {
	return request.post<AuthorityModifiedResponse | undefined>({
		url: '/system/sys-authority/saveRoleAuthority',
		data
	})
}

export const deleteAuthorityApi = (id: number) => {
	return request.delete<AuthorityModifiedResponse | undefined>({
		url: '/system/sys-authority/deleteAuthority/' + id
	})
}

export const getAllAuthorityIdByRoleIdApi = (id: number) => {
	return request.get<number[]>({
		url: '/system/sys-authority/readOnly/getAllAuthorityIdByRoleId/' + id
	})
}

export const getAllRoleApi = () => {
	return request.get<SysRole[]>({
		url: '/system/sys-authority/readOnly/getAllRole'
	})
}
